# Created by 黄景涛
# DATE: 2025/4/29
from var_hot_loading.tools.yaml_util import read_yaml
from var_hot_loading.parser import render, NameSpace
import logging

logger = logging.getLogger()


def t_case_1():
    # 模拟读取用例数据
    case: dict = read_yaml('app/test_case_1.yaml')[0]

    # 模拟传入当前请求/响应信息
    custom_context = {"request": {"data": {"name": "主机1"}},
                      "response": {"data": {"info": [{"name": "响应名称2"}, {"name": ""}]}}}
    NameSpace.custom_context = custom_context

    for k, v in case.items():
        v = render(v)
        logger.info(f'{k}：{v}, \tv的类型={type(v)}')


def t_case_2():
    case: dict = read_yaml('app/test_case_1.yaml')[0]

    # custom_context = {"request": {"data": {"name": "主机1"}},
    #                   "response": {"data": {"info": [{"name": "响应名称3"}, {"name": "响应名称4"}]}}}
    # VarNameSpace.custom_context = custom_context

    for k, v in case.items():
        v = render(v)
        logger.info(f'{k}：{v}, \tv的类型={type(v)}')


if __name__ == '__main__':
    t_case_1()
    t_case_2()
